/*
 * ADC.c
 *
 * Created: 08.02.2013 17:22:41
 *  Author: saenko
 */ 
#include <avr/io.h>
#include <avr/interrupt.h>

unsigned char ADC_data;
unsigned char ADC_flag_complete;

void ADC_init(void)
{
	ADMUX = (1<<REFS1)|(1<<REFS0)|(1<<ADLAR)|(0<<MUX3)|(0<<MUX2)|(0<<MUX1)|(0<<MUX0);
	ADCSRA = (1<<ADEN)|(1<<ADSC)|(1<<ADIE)|(1<<ADPS2)|(1<<ADPS1);
	DIDR0 = (1<<ADC0D);
}

ISR(ADC_vect)
{
	ADC_data = ADCH;
	ADC_flag_complete = 1;
}
